<?php

/**
 * This is the model class for table "site_guestbook".
 *
 * The followings are the available columns in table 'site_guestbook':
 * @property string $guestbook_id
 * @property string $guestbook_sender
 * @property string $guestbook_email
 * @property string $guestbook_phone
 * @property string $guestbook_url
 * @property string $guestbook_subject
 * @property string $guestbook_message
 * @property string $guestbook_input_datetime
 * @property string $guestbook_is_read
 */
class site_guestbook extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return site_guestbook the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'site_guestbook';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('guestbook_sender, guestbook_email, guestbook_phone', 'length', 'max' => 50),
            array('guestbook_url', 'length', 'max' => 255),
            array('guestbook_subject', 'length', 'max' => 100),
            array('guestbook_is_read', 'length', 'max' => 1),
            array('guestbook_message, guestbook_input_datetime', 'safe'),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('guestbook_id, guestbook_sender, guestbook_email, guestbook_phone, guestbook_url, guestbook_subject, guestbook_message, guestbook_input_datetime, guestbook_is_read', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'guestbook_id' => 'Guestbook',
            'guestbook_sender' => 'Sender',
            'guestbook_email' => 'Email',
            'guestbook_phone' => 'Phone',
            'guestbook_url' => 'Url',
            'guestbook_subject' => 'Subject',
            'guestbook_message' => 'Message',
            'guestbook_input_datetime' => 'Input Date',
            'guestbook_is_read' => 'Is Read',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('guestbook_id', $this->guestbook_id, true);
        $criteria->compare('guestbook_sender', $this->guestbook_sender, true);
        $criteria->compare('guestbook_email', $this->guestbook_email, true);
        $criteria->compare('guestbook_phone', $this->guestbook_phone, true);
        $criteria->compare('guestbook_url', $this->guestbook_url, true);
        $criteria->compare('guestbook_subject', $this->guestbook_subject, true);
        $criteria->compare('guestbook_message', $this->guestbook_message, true);
        $criteria->compare('guestbook_input_datetime', $this->guestbook_input_datetime, true);
        $criteria->compare('guestbook_is_read', $this->guestbook_is_read, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }

}